/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author sky
 */
@Entity
@Table(name = "PLAY_LIST")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PlayList.findAll", query = "SELECT p FROM PlayList p"),
    @NamedQuery(name = "PlayList.findByPlayListId", query = "SELECT p FROM PlayList p WHERE p.playListId = :playListId"),
    @NamedQuery(name = "PlayList.findByPlayListName", query = "SELECT p FROM PlayList p WHERE p.playListName = :playListName")})
public class PlayList implements Serializable {
    @Basic(optional = false)
    @Column(name = "PLAY_LIST_DATE")
    @Temporal(TemporalType.DATE)
    private Date playListDate;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "PLAY_LIST_ID")
    private Long playListId;
    @Basic(optional = false)
    @Column(name = "PLAY_LIST_NAME")
    private String playListName;
    @JoinTable(name = "SONG_PLAY_LIST", joinColumns = {
        @JoinColumn(name = "PLAY_LIST_ID", referencedColumnName = "PLAY_LIST_ID")}, inverseJoinColumns = {
        @JoinColumn(name = "SONG_ID", referencedColumnName = "SONG_ID")})
    @ManyToMany
    private List<Song> songList;

    public PlayList() {
    }

    public PlayList(Long playListId) {
        this.playListId = playListId;
    }

    public PlayList(Long playListId, String playListName) {
        this.playListId = playListId;
        this.playListName = playListName;
    }

    public Long getPlayListId() {
        return playListId;
    }

    public void setPlayListId(Long playListId) {
        this.playListId = playListId;
    }

    public String getPlayListName() {
        return playListName;
    }

    public void setPlayListName(String playListName) {
        this.playListName = playListName;
    }

    @XmlTransient
    public List<Song> getSongList() {
        return songList;
    }

    public void setSongList(List<Song> songList) {
        this.songList = songList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (playListId != null ? playListId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PlayList)) {
            return false;
        }
        PlayList other = (PlayList) object;
        if ((this.playListId == null && other.playListId != null) || (this.playListId != null && !this.playListId.equals(other.playListId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.PlayList[ playListId=" + playListId + " ]";
    }

    public Date getPlayListDate() {
        return playListDate;
    }

    public void setPlayListDate(Date playListDate) {
        this.playListDate = playListDate;
    }
    
}
